﻿using System;
using System.Collections.Generic;
using System.Drawing;

using Microsoft.DirectX;

namespace NGE.MENU
{
    class MsgBox : Panelbox
    {
        public MsgBox(Game g)
            : base(g)
        {            
            Name = "信息";

            Location = new Vector3(0, 0, 0);
            Size = new System.Drawing.Size(320, 240);
            BGColor = Color.Black;

            label = new Textbox();
            label.Interval = 33;
            label.Location = new Vector3();

            AddElement(label);

            this.OnPanelboxOpen += new MenuEvent(MsgBox_OnPanelboxOpen);
            this.OnPanelboxClose += new MenuEvent(MsgBox_OnPanelboxClose);
        }

        void MsgBox_OnPanelboxClose(object sender, object arg)
        {

        }

        void MsgBox_OnPanelboxOpen(object sender, object arg)
        {
            if (arg is string)
            {
                string txt = (string)arg;

                label.Text = txt;

                Size = Util.GetTextSize(txt, (int)label.TextFont.Height);
            }
        }

        protected override void OnKeyboardEventCode(object sender, int key, KeyboardState ks)
        {
            if (key == game.Option.KeyB)
            {
                return;
            }
            base.OnKeyboardEventCode(sender, key, ks);
            if (ks == KeyboardState.KeyUp)
            {
                if (key == game.Option.KeyA)
                {
                    game.MenuCOM.Close();
                }
            }
        }

        Textbox label;
    }
}
